package com.vit.mep;


import com.vit.mep.model.BankResponse;
import com.vit.mep.model.MepUser;
import com.vit.mep.model.TransactionData;

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;


public class MepApp  extends UiApplication 
{
	
	protected MepUser _mepUser;
	
	public MepUser getMepUser() {
		return _mepUser;
	}

	public void setMepUser(MepUser _mepUser) {
		this._mepUser = _mepUser;
	}
    
    private LoginScreen loginScreen;
    private MepReaderScreen readerScreen;
    private ConfirmationScreen confirmationScreen;
    private VoucherScreen voucherScreen;
	
	public static void main(String[] args)
	{
 
		MepApp app = new MepApp();
		app.enterEventDispatcher();

	}
    
	public MepApp ()
	{		
		loginScreen = new LoginScreen(this);
		readerScreen = new MepReaderScreen(this);
		confirmationScreen = new ConfirmationScreen(this);
		voucherScreen = new VoucherScreen(this);
		pushScreen(loginScreen);
	}
	
	public void showConfirmationScreen(TransactionData td){
		if(readerScreen != null){			 
			popScreen(readerScreen);
		}
		confirmationScreen.repaint(td);
		pushScreen(confirmationScreen);
	}
	
	
	public void showVoucher(BankResponse br){
		if(confirmationScreen!= null){
			popScreen(confirmationScreen);			
		}				
		pushScreen(voucherScreen);
		voucherScreen.setBankResponse(br);
	}
	
	
	public void init(MainScreen screen){
		if(screen != null){			 
			popScreen(screen);
		}		
		pushScreen(loginScreen);
	}
	
	
	
	public void showReaderScreen(){
		if(loginScreen != null){
			popScreen(loginScreen);
		}		
		pushScreen(readerScreen);
	}
	
	
	public void showReaderScreenFromConfirmation(){
		if(confirmationScreen != null){
			popScreen(confirmationScreen);
		}		
		pushScreen(readerScreen);
	}
	
	public void endApp(){
		System.exit(getProcessId());
	}
	

	
	public void showLoginScreen(){
		if(readerScreen != null){
			popScreen(readerScreen);	
		}		
		pushScreen(loginScreen);
	}

	public LoginScreen getLoginScreen() {
		return loginScreen;
	}

	public void setLoginScreen(LoginScreen loginScreen) {
		this.loginScreen = loginScreen;
	}

	public MepReaderScreen getReaderScreen() {
		return readerScreen;
	}

	public void setReaderScreen(MepReaderScreen readerScreen) {
		this.readerScreen = readerScreen;
	}

	public ConfirmationScreen getConfirmationScreen() {
		return confirmationScreen;
	}

	public void setConfirmationScreen(ConfirmationScreen confirmationScreen) {
		this.confirmationScreen = confirmationScreen;
	}

	public VoucherScreen getVoucherScreen() {
		return voucherScreen;
	}

	public void setVoucherScreen(VoucherScreen voucherScreen) {
		this.voucherScreen = voucherScreen;
	}
	
	
	
 	
}//class